Ext.define("NF.controller.Farms", {
    extend:"Ext.app.Controller",
    views:['farm.List','farm.Edit'],
    stores:['Farms'],
    models:['Farm'],
    init: function() {
        this.control({
            'viewport > farmsList':{
                itemdblclick:this.editName
            },
            'farmEdit button[action = save]':{
                click:this.updateFarm
            }
        })
    },
    editName:function(grid, record) {
        console.log("You dbl clicked the panel " + record.get('name'));
        var view = Ext.widget('farmEdit');
        view.down('form').loadRecord(record);
    },
    updateFarm:function(button) {
        var win = button.up('window');
        var form = win.down('form');
        var record = form.getRecord();
        var values = form.getValues();
        record.set(values);
        win.close();
    }
});